package xyz.xtt.admin.constants;

import java.util.Arrays;
import java.util.Objects;

/**
 * @author huqibo
 * 
 *         资产类型枚举
 */
public enum FileTypeEnum {
	/**
	 * 图片
	 */
	IMG(0, "图片"),

	/**
	 * 音频
	 */
	AUDIO(1, "音频"),

	/**
	 * 视频
	 */
	VIDEO(2, "视频");

	/**
	 * 编码
	 */
	private int code;
	/**
	 * 描述
	 */
	private String desc;

	FileTypeEnum(int code, String desc) {
		this.code = code;
		this.desc = desc;
	}

	public int code() {
		return code;
	}

	public String desc() {
		return desc;
	}

	public static boolean checkType(String checkType) {
		return Arrays.asList(FileTypeEnum.values()).stream().anyMatch(x -> Objects.equals(x.name(), checkType));
	}

	public static FileTypeEnum queryConvert(Integer code) {
		return Arrays.asList(FileTypeEnum.values()).stream().filter(x -> Objects.equals(x.code(), code)).findAny().orElseGet(null);
	}

}
